
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 17/11/2013 20:29:50
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class InnoAppUser
    /// </summary>
    [Serializable]
    public partial class InnoAppUser : _DomainLayer_Base  
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual System.Guid Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FK_Application.
        /// </summary>
        /// <value>The FK_Application.</value>
        /// <remarks>
        /// Foregn key of InnoAppUser
        /// 
        /// </remarks>
        public virtual System.Guid FK_Application
        {
            get { return _fK_Application; }
            set
            {
                if (_fK_Application != value)
                {
                    if (InnoApplication != null && InnoApplication.Id != value)
                    {
                        InnoApplication = null;
                    }
                    _fK_Application = value;
                }
            }
        }
        private System.Guid _fK_Application;
    	
        /// <summary>
        /// Gets or sets CreationDate.
        /// </summary>
        /// <value>The CreationDate.</value>
        public virtual Nullable<System.DateTime> CreationDate
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Username.
        /// </summary>
        /// <value>The Username.</value>
        public virtual string Username
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Email.
        /// </summary>
        /// <value>The Email.</value>
        public virtual string Email
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Password.
        /// </summary>
        /// <value>The Password.</value>
        public virtual string Password
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets PasswordQuestion.
        /// </summary>
        /// <value>The PasswordQuestion.</value>
        public virtual string PasswordQuestion
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets PasswordAnswer.
        /// </summary>
        /// <value>The PasswordAnswer.</value>
        public virtual string PasswordAnswer
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets IsApproved.
        /// </summary>
        /// <value>The IsApproved.</value>
        public virtual bool IsApproved
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets LastActivityDate.
        /// </summary>
        /// <value>The LastActivityDate.</value>
        public virtual System.DateTime LastActivityDate
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets LastLoginDate.
        /// </summary>
        /// <value>The LastLoginDate.</value>
        public virtual Nullable<System.DateTime> LastLoginDate
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets LastPasswordChangedDate.
        /// </summary>
        /// <value>The LastPasswordChangedDate.</value>
        public virtual Nullable<System.DateTime> LastPasswordChangedDate
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets IsOnline.
        /// </summary>
        /// <value>The IsOnline.</value>
        public virtual Nullable<bool> IsOnline
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets IsLockedOut.
        /// </summary>
        /// <value>The IsLockedOut.</value>
        public virtual bool IsLockedOut
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets LastLockedOutDate.
        /// </summary>
        /// <value>The LastLockedOutDate.</value>
        public virtual Nullable<System.DateTime> LastLockedOutDate
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FailedPasswordAttemptCount.
        /// </summary>
        /// <value>The FailedPasswordAttemptCount.</value>
        public virtual Nullable<int> FailedPasswordAttemptCount
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FailedPasswordAttemptWindowStart.
        /// </summary>
        /// <value>The FailedPasswordAttemptWindowStart.</value>
        public virtual Nullable<System.DateTime> FailedPasswordAttemptWindowStart
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FailedPasswordAnswerAttemptCount.
        /// </summary>
        /// <value>The FailedPasswordAnswerAttemptCount.</value>
        public virtual Nullable<int> FailedPasswordAnswerAttemptCount
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FailedPasswordAnswerAttemptWindowStart.
        /// </summary>
        /// <value>The FailedPasswordAnswerAttemptWindowStart.</value>
        public virtual Nullable<System.DateTime> FailedPasswordAnswerAttemptWindowStart
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets LastModified.
        /// </summary>
        /// <value>The LastModified.</value>
        public virtual Nullable<System.DateTime> LastModified
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Comment.
        /// </summary>
        /// <value>The Comment.</value>
        public virtual string Comment
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets IsAnonymous.
        /// </summary>
        /// <value>The IsAnonymous.</value>
        public virtual bool IsAnonymous
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion

        #region Navigation Properties
    
        /// <summary>
        /// Link InnoAppUser to all Contact
        /// </summary>
        public virtual ICollection<Contact> Contact
        {
            get
            {
                if (_contact == null)
                {
                    var newCollection = new FixupCollection<Contact>();
                    newCollection.CollectionChanged += FixupContact;
                    _contact = newCollection;
                }
                return _contact;
            }
            set
            {
                if (!ReferenceEquals(_contact, value))
                {
                    var previousValue = _contact as FixupCollection<Contact>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupContact;
                    }
                    _contact = value;
                    var newValue = value as FixupCollection<Contact>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupContact;
                    }
                }
            }
        }
        private ICollection<Contact> _contact;
    
        /// <summary>
        /// Link InnoAppUser to all ManagedContent
        /// </summary>
        public virtual ICollection<ManagedContent> ManagedContent
        {
            get
            {
                if (_managedContent == null)
                {
                    var newCollection = new FixupCollection<ManagedContent>();
                    newCollection.CollectionChanged += FixupManagedContent;
                    _managedContent = newCollection;
                }
                return _managedContent;
            }
            set
            {
                if (!ReferenceEquals(_managedContent, value))
                {
                    var previousValue = _managedContent as FixupCollection<ManagedContent>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupManagedContent;
                    }
                    _managedContent = value;
                    var newValue = value as FixupCollection<ManagedContent>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupManagedContent;
                    }
                }
            }
        }
        private ICollection<ManagedContent> _managedContent;
    
        /// <summary>
        /// Link InnoAppUser to all ManagedContent
        /// </summary>
        public virtual ICollection<ManagedContent> ManagedContent1
        {
            get
            {
                if (_managedContent1 == null)
                {
                    var newCollection = new FixupCollection<ManagedContent>();
                    newCollection.CollectionChanged += FixupManagedContent1;
                    _managedContent1 = newCollection;
                }
                return _managedContent1;
            }
            set
            {
                if (!ReferenceEquals(_managedContent1, value))
                {
                    var previousValue = _managedContent1 as FixupCollection<ManagedContent>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupManagedContent1;
                    }
                    _managedContent1 = value;
                    var newValue = value as FixupCollection<ManagedContent>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupManagedContent1;
                    }
                }
            }
        }
        private ICollection<ManagedContent> _managedContent1;
        public virtual InnoApplication InnoApplication
        {
            get { return _innoApplication; }
            set
            {
                if (!ReferenceEquals(_innoApplication, value))
                {
                    var previousValue = _innoApplication;
                    _innoApplication = value;
                    FixupInnoApplication(previousValue);
                }
            }
        }
        private InnoApplication _innoApplication;
        public virtual InnoProfile InnoProfile
        {
            get { return _innoProfile; }
            set
            {
                if (!ReferenceEquals(_innoProfile, value))
                {
                    var previousValue = _innoProfile;
                    _innoProfile = value;
                    FixupInnoProfile(previousValue);
                }
            }
        }
        private InnoProfile _innoProfile;
    
        /// <summary>
        /// Link InnoAppUser to all InnoUsersInRoles
        /// </summary>
        public virtual ICollection<InnoUsersInRoles> InnoUsersInRoles
        {
            get
            {
                if (_innoUsersInRoles == null)
                {
                    var newCollection = new FixupCollection<InnoUsersInRoles>();
                    newCollection.CollectionChanged += FixupInnoUsersInRoles;
                    _innoUsersInRoles = newCollection;
                }
                return _innoUsersInRoles;
            }
            set
            {
                if (!ReferenceEquals(_innoUsersInRoles, value))
                {
                    var previousValue = _innoUsersInRoles as FixupCollection<InnoUsersInRoles>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupInnoUsersInRoles;
                    }
                    _innoUsersInRoles = value;
                    var newValue = value as FixupCollection<InnoUsersInRoles>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupInnoUsersInRoles;
                    }
                }
            }
        }
        private ICollection<InnoUsersInRoles> _innoUsersInRoles;

        #endregion

        #region Association Fixup
    
        private void FixupInnoApplication(InnoApplication previousValue)
        {
            if (previousValue != null && previousValue.InnoAppUser.Contains(this))
            {
                previousValue.InnoAppUser.Remove(this);
            }
    
            if (InnoApplication != null)
            {
                if (!InnoApplication.InnoAppUser.Contains(this))
                {
                    InnoApplication.InnoAppUser.Add(this);
                }
                if (FK_Application != InnoApplication.Id)
                {
                    FK_Application = InnoApplication.Id;
                }
            }
        }
    
        private void FixupInnoProfile(InnoProfile previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.InnoAppUser, this))
            {
                previousValue.InnoAppUser = null;
            }
    
            if (InnoProfile != null)
            {
                InnoProfile.InnoAppUser = this;
            }
        }
    
        private void FixupContact(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (Contact item in e.NewItems)
                {
                    item.InnoAppUser = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (Contact item in e.OldItems)
                {
                    if (ReferenceEquals(item.InnoAppUser, this))
                    {
                        item.InnoAppUser = null;
                    }
                }
            }
        }
    
        private void FixupManagedContent(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (ManagedContent item in e.NewItems)
                {
                    item.InnoAppUser = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (ManagedContent item in e.OldItems)
                {
                    if (ReferenceEquals(item.InnoAppUser, this))
                    {
                        item.InnoAppUser = null;
                    }
                }
            }
        }
    
        private void FixupManagedContent1(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (ManagedContent item in e.NewItems)
                {
                    item.InnoAppUser1 = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (ManagedContent item in e.OldItems)
                {
                    if (ReferenceEquals(item.InnoAppUser1, this))
                    {
                        item.InnoAppUser1 = null;
                    }
                }
            }
        }
    
        private void FixupInnoUsersInRoles(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (InnoUsersInRoles item in e.NewItems)
                {
                    item.InnoAppUser = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (InnoUsersInRoles item in e.OldItems)
                {
                    if (ReferenceEquals(item.InnoAppUser, this))
                    {
                        item.InnoAppUser = null;
                    }
                }
            }
        }

        #endregion

    }
}
